import java.util.Arrays;

public class demo1 {
    public static void main(String[] args) {
        int[]nums={1,2,2,2,3,5};

        int k = removeElement(5,nums);
        System.out.println(k);
        System.out.println(Arrays.toString(nums));
    }
    public  static  int removeElement(int val,int[]nums){
        int size=nums.length;
        int i = 0;
      while (true){
          for ( i = 0; i <size ; i++) {
              if(nums[i]==val){
                  break;
              }
          }
          if(i==size){
              break;
          }                        //6
          for (int pos = i+1; pos <size ; pos++) {
              nums[pos-1]=nums[pos];

          }
          size--;
      }



        return size;
    }

}
